package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.CaractPP;
import org.gap.domain.Tiers;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class CaractPPServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CaractPPService service;

	/**
	 * Instantiates a new CaractPPServiceTest.
	 *
	 */
	public CaractPPServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Save an existing CaractPP entity
	 * 
	 */
	@Test
	public void saveCaractPP() {
		// TODO: JUnit - Populate test inputs for operation: saveCaractPP 
		CaractPP caractpp = new org.gap.domain.CaractPP();
		service.saveCaractPP(caractpp);
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCaractPPByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCaractPPByPrimaryKey 
		Integer cppTiers = 0;
		CaractPP response = null;
		response = service.findCaractPPByPrimaryKey(cppTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: findCaractPPByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Save an existing Tiers entity
	 * 
	 */
	@Test
	public void saveCaractPPTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveCaractPPTiers 
		Integer cppTiers_1 = 0;
		Tiers related_tiers = new org.gap.domain.Tiers();
		CaractPP response = null;
		response = service.saveCaractPPTiers(cppTiers_1, related_tiers);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCaractPPTiers
	}

	/**
	 * Operation Unit Test
	 * Load an existing CaractPP entity
	 * 
	 */
	@Test
	public void loadCaractPPs() {
		Set<CaractPP> response = null;
		response = service.loadCaractPPs();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCaractPPs
	}

	/**
	 * Operation Unit Test
	 * Delete an existing CaractPP entity
	 * 
	 */
	@Test
	public void deleteCaractPP() {
		// TODO: JUnit - Populate test inputs for operation: deleteCaractPP 
		CaractPP caractpp_1 = new org.gap.domain.CaractPP();
		service.deleteCaractPP(caractpp_1);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Tiers entity
	 * 
	 */
	@Test
	public void deleteCaractPPTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteCaractPPTiers 
		Integer caractpp_cppTiers = 0;
		Integer related_tiers_tieTiers = 0;
		CaractPP response = null;
		response = service.deleteCaractPPTiers(caractpp_cppTiers, related_tiers_tieTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCaractPPTiers
	}

	/**
	 * Operation Unit Test
	 * Return all CaractPP entity
	 * 
	 */
	@Test
	public void findAllCaractPPs() {
		// TODO: JUnit - Populate test inputs for operation: findAllCaractPPs 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CaractPP> response = null;
		response = service.findAllCaractPPs(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCaractPPs
	}

	/**
	 * Operation Unit Test
	 * Return a count of all CaractPP entity
	 * 
	 */
	@Test
	public void countCaractPPs() {
		Integer response = null;
		response = service.countCaractPPs();
		// TODO: JUnit - Add assertions to test outputs of operation: countCaractPPs
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
